package com.itheima.controller;

import com.itheima.properties.properties;
import com.itheima.service.UserService;
import com.itheima.user.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "/user")
//@RefreshScope //自动热更新啊
public class UserController {

    @Autowired
    private UserService userService;

    @Autowired
    private properties properties;

//    @Value("${person.name}")
//    private String name;
//
//    @Value("${person.age}")
//    private String age;

    @GetMapping("/hello")
    public String hello(@RequestHeader(name = "name") String name) {
        return "我叫" + properties.getName() + " " + "年龄是" + properties.getAge() +"请求头为"+ name;
    }

    /***
     * 根据id查询用户详情
     */
    @GetMapping(value = "/{id}")
    public User one(@PathVariable(value = "id") Long id){
        return userService.findById(id);
    }
}
